﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SisLegal.Model;

namespace SisLegal.Maestros
{
    public partial class ViaProceduralNewForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DDL_Type_Process.DataSource = Enumeration.GetAll<eTypeProcess>();
                DDL_Type_Process.DataTextField = "Value";
                DDL_Type_Process.DataValueField = "Key";
                DDL_Type_Process.DataBind();
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            Model.ViaProceduralManager manager = new Model.ViaProceduralManager();
            Model.ViaProcedural objecto = new Model.ViaProcedural();

            objecto.Name = this.txtName.Text;
            objecto.ProcessID = Convert.ToInt32(this.DDL_Type_Process.SelectedItem.Value);
            int newArticleID = manager.Save(objecto);

            if (newArticleID != 0)
            {
                //lblConfirmation.Text = "Grabado Satifactoriamente";
                //lblConfirmation.Visible = true;
            }
            else
            {
                //lblConfirmation.Text = "Error en la Grabacion";
                //lblConfirmation.Visible = true;
            }

            Response.Redirect("~/Maestros/ViaProceduralListView.aspx");

            //ClearForm();
            
        }

        private void ClearForm()
        {
            this.txtName.Text = String.Empty;
        }
    }
}